﻿using System;
using System.Data;
using System.Collections.Generic;
using Royalsoft.Common;
using NJL.Model;
using NJL.DALFactory;
using NJL.IDAL;
namespace NJL.BLL
{
	/// <summary>
	/// NJL_LOCAL_COLOR_NEWS
	/// </summary>
	public partial class NJL_LOCAL_COLOR_NEWS
	{
		private readonly INJL_LOCAL_COLOR_NEWS dal=DataAccess.CreateNJL_LOCAL_COLOR_NEWS();
		public NJL_LOCAL_COLOR_NEWS()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string ID)
		{
			return dal.Exists(ID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(NJL.Model.NJL_LOCAL_COLOR_NEWS model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(NJL.Model.NJL_LOCAL_COLOR_NEWS model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string ID)
		{
			
			return dal.Delete(ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string IDlist )
		{
			return dal.DeleteList(IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public NJL.Model.NJL_LOCAL_COLOR_NEWS GetModel(string ID)
		{
			
			return dal.GetModel(ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public NJL.Model.NJL_LOCAL_COLOR_NEWS GetModelByCache(string ID)
		{
			
			string CacheKey = "NJL_LOCAL_COLOR_NEWSModel-" + ID;
			object objModel = Royalsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(ID);
					if (objModel != null)
					{
						int ModelCache = Royalsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Royalsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (NJL.Model.NJL_LOCAL_COLOR_NEWS)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<NJL.Model.NJL_LOCAL_COLOR_NEWS> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}		/// <summary>
        /// 获得数据列表
        /// </summary>
        public List<NJL.Model.NJL_LOCAL_COLOR_NEWS> GetModelList(int Top,string strWhere,string filedOrder)
        {
            DataSet ds = dal.GetList(Top,strWhere,filedOrder);
            return DataTableToList(ds.Tables[0]);
        }
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<NJL.Model.NJL_LOCAL_COLOR_NEWS> DataTableToList(DataTable dt)
		{
			List<NJL.Model.NJL_LOCAL_COLOR_NEWS> modelList = new List<NJL.Model.NJL_LOCAL_COLOR_NEWS>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				NJL.Model.NJL_LOCAL_COLOR_NEWS model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new NJL.Model.NJL_LOCAL_COLOR_NEWS();
					if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="")
					{
					model.ID=dt.Rows[n]["ID"].ToString();
					}
					if(dt.Rows[n]["NJL_LOCAL_COLOR_ID"]!=null && dt.Rows[n]["NJL_LOCAL_COLOR_ID"].ToString()!="")
					{
					model.NJL_LOCAL_COLOR_ID=dt.Rows[n]["NJL_LOCAL_COLOR_ID"].ToString();
					}
					if(dt.Rows[n]["SEO_TITLE"]!=null && dt.Rows[n]["SEO_TITLE"].ToString()!="")
					{
					model.SEO_TITLE=dt.Rows[n]["SEO_TITLE"].ToString();
					}
					if(dt.Rows[n]["SEO_KEYWORDS"]!=null && dt.Rows[n]["SEO_KEYWORDS"].ToString()!="")
					{
					model.SEO_KEYWORDS=dt.Rows[n]["SEO_KEYWORDS"].ToString();
					}
					if(dt.Rows[n]["SEO_DESCRIPTION"]!=null && dt.Rows[n]["SEO_DESCRIPTION"].ToString()!="")
					{
					model.SEO_DESCRIPTION=dt.Rows[n]["SEO_DESCRIPTION"].ToString();
					}
					if(dt.Rows[n]["NEWS_TITLE"]!=null && dt.Rows[n]["NEWS_TITLE"].ToString()!="")
					{
					model.NEWS_TITLE=dt.Rows[n]["NEWS_TITLE"].ToString();
					}
					if(dt.Rows[n]["NEWS_SUBJECT_TITLE"]!=null && dt.Rows[n]["NEWS_SUBJECT_TITLE"].ToString()!="")
					{
					model.NEWS_SUBJECT_TITLE=dt.Rows[n]["NEWS_SUBJECT_TITLE"].ToString();
					}
					if(dt.Rows[n]["NEWS_CONTECT"]!=null && dt.Rows[n]["NEWS_CONTECT"].ToString()!="")
					{
					model.NEWS_CONTECT=dt.Rows[n]["NEWS_CONTECT"].ToString();
					}
					if(dt.Rows[n]["NEWS_TAG"]!=null && dt.Rows[n]["NEWS_TAG"].ToString()!="")
					{
					model.NEWS_TAG=dt.Rows[n]["NEWS_TAG"].ToString();
					}
					if(dt.Rows[n]["CREATE_DATE_TIME"]!=null && dt.Rows[n]["CREATE_DATE_TIME"].ToString()!="")
					{
						model.CREATE_DATE_TIME=DateTime.Parse(dt.Rows[n]["CREATE_DATE_TIME"].ToString());
					}
					if(dt.Rows[n]["CREATE_USER_ID"]!=null && dt.Rows[n]["CREATE_USER_ID"].ToString()!="")
					{
					model.CREATE_USER_ID=dt.Rows[n]["CREATE_USER_ID"].ToString();
					}
					if(dt.Rows[n]["CREATE_USER_NAME"]!=null && dt.Rows[n]["CREATE_USER_NAME"].ToString()!="")
					{
					model.CREATE_USER_NAME=dt.Rows[n]["CREATE_USER_NAME"].ToString();
					}
					if(dt.Rows[n]["UPDATE_DATE_TIME"]!=null && dt.Rows[n]["UPDATE_DATE_TIME"].ToString()!="")
					{
						model.UPDATE_DATE_TIME=DateTime.Parse(dt.Rows[n]["UPDATE_DATE_TIME"].ToString());
					}
					if(dt.Rows[n]["UPDATE_USER_ID"]!=null && dt.Rows[n]["UPDATE_USER_ID"].ToString()!="")
					{
					model.UPDATE_USER_ID=dt.Rows[n]["UPDATE_USER_ID"].ToString();
					}
					if(dt.Rows[n]["UPDATE_USER_NAME"]!=null && dt.Rows[n]["UPDATE_USER_NAME"].ToString()!="")
					{
					model.UPDATE_USER_NAME=dt.Rows[n]["UPDATE_USER_NAME"].ToString();
					}
					if(dt.Rows[n]["SORT"]!=null && dt.Rows[n]["SORT"].ToString()!="")
					{
						model.SORT=int.Parse(dt.Rows[n]["SORT"].ToString());
					}
					if(dt.Rows[n]["VISIT_COUNT"]!=null && dt.Rows[n]["VISIT_COUNT"].ToString()!="")
					{
						model.VISIT_COUNT=int.Parse(dt.Rows[n]["VISIT_COUNT"].ToString());
					}
					if(dt.Rows[n]["COMMENT_COUNT"]!=null && dt.Rows[n]["COMMENT_COUNT"].ToString()!="")
					{
						model.COMMENT_COUNT=int.Parse(dt.Rows[n]["COMMENT_COUNT"].ToString());
					}
					if(dt.Rows[n]["LAST_COMMENT_DATE_TIME"]!=null && dt.Rows[n]["LAST_COMMENT_DATE_TIME"].ToString()!="")
					{
						model.LAST_COMMENT_DATE_TIME=DateTime.Parse(dt.Rows[n]["LAST_COMMENT_DATE_TIME"].ToString());
					}
					if(dt.Rows[n]["LAST_VISIT_DATE_TIME"]!=null && dt.Rows[n]["LAST_VISIT_DATE_TIME"].ToString()!="")
					{
						model.LAST_VISIT_DATE_TIME=DateTime.Parse(dt.Rows[n]["LAST_VISIT_DATE_TIME"].ToString());
					}
					if(dt.Rows[n]["IMAGE_CODE"]!=null && dt.Rows[n]["IMAGE_CODE"].ToString()!="")
					{
					model.IMAGE_CODE=dt.Rows[n]["IMAGE_CODE"].ToString();
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

